﻿using DoNet.Handlers.Commands;
using DoNet.System.IServices;
using MediatR;

namespace DoNet.Handlers.Handlers
{
    /// <summary>
    /// 登录日志处理命令
    /// </summary>
    public class LoginLogCommandHandler : IRequestHandler<LoginLogCommand, bool>
    {
        private readonly ILoginLogService _loginLogService;

        public LoginLogCommandHandler(ILoginLogService loginLogService)
        {
            _loginLogService = loginLogService;
        }

        public async Task<bool> Handle(LoginLogCommand request, CancellationToken cancellationToken)
        {
            int row = 0;
            var loginLog = request.LoginLogInputDto;
            if (loginLog != null)
            {
                row = await _loginLogService.InsertAsync(loginLog);
            }
            return row > 0;
        }
    }
}
